<!DOCTYPE html>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;

%>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="IMG/favicon.ico">


    <title>录入销售记录</title>

    <!-- Bootstrap core CSS -->
    <link href="static/css/dist/css/bootstrap.min.css?v=1" rel="stylesheet">
    <!-- Bootstrap theme -->
    <link href="static/css/dist/css/bootstrap-theme.min.css" rel="stylesheet">
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="static/css/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="static/css/theme.css" rel="stylesheet">
    <script src="static/js/echarts.min.js"></script>
    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]>
    <script src="static/css/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="static/css/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>

    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>

    <![endif]-->
</head>

<body role="document">

<!-- Fixed navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="main">IBONUS</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <!--<li class="active"><a href="#"></a></li>-->
                <li><a href="salesGLYIntoPage"><span style="font-family:微软雅黑; ">销售统计</span></a></li>
                <li><a href="productGLYIntoPage" class="active"><span style="font-family:微软雅黑; ">产品奖励配置</span></a></li>
                <li><a href="userGLYIntoPage"><span style="font-family:微软雅黑; ">人员配置</span></a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">${userInfo.userRealname} <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="logout"><span style="font-family:微软雅黑; ">注销</span></a></li>
                        <li><a href="updatePasswordPage"><span style="font-family:微软雅黑; ">修改密码</span></a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <!--/.nav-collapse -->
    </div>
</nav>


<div class="container">

    <!-- Main jumbotron for a primary marketing message or call to action -->

    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">
      <span style="font-family:微软雅黑;">
      配置产品信息页面
        <%--<button type="button" id="loadButton" name="loadButton"  data-toggle="modal" data-target="#addModal"  class="btn btn-default" >--%>
          <%--新增--%>
        <%--</button>--%>
        <%--<button type="button" id="loadTypeButton" name="loadTypeButton"  data-toggle="modal" data-target="#addModalType"  class="btn btn-default" >--%>
          <%--新增产品类型--%>
        <%--</button>--%>
         <span style="color:red">${msg}</span>
      </span>
        </div>
        <div class="panel-body">
            <p><span style="font-family:微软雅黑;">此页面用于配置产品，包括产品的奖励额和产品类型</span></p>
        </div>
        <!-- Modal -->


        <!--Model ALL-->
        <!-- Modal -->
        <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="addProductInfo">产品配置</h4>
                    </div>
                    <div class="modal-body" style="font-family:微软雅黑;">
                        <form>
                            <div class="form-group">
                                <label for="productName">产品名称</label>
                                <input class="form-control" id="productName" name="productName">
                            </div>

                            <div class="form-group">
                                <label for="productType">产品类型</label>
                                <select class="form-control" id="productType" name="productType">
                                    <option>全部</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="bonusNumber">激励金额</label>
                                <input class="form-control" id="bonusNumber" name="bonusNumber">
                            </div>

                            <div class="form-group" align="right">

                                <button type="submit" id="addProductBonus" name="addProductBonus"
                                        class="btn btn-primary">添加
                                </button>
                                &nbsp;&nbsp;&nbsp;
                            </div>
                        </form>

                    </div>

                </div>
            </div>
        </div>
        <div class="modal fade" id="addModalType" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="addModalLabel">产品类型配置</h4>
                    </div>
                    <div class="modal-body" style="font-family:微软雅黑;">
                        <form>
                            <div class="form-group">
                                <label for="exampleInputEmail1">产品类型</label>
                                <input class="form-control" id="exampleInputEmail1" name="productType">
                            </div>

                            <div class="form-group" align="right">
                                <button type="submit" id="addProductType" name="addProductType" class="btn btn-primary">
                                    添加
                                </button>
                                &nbsp;&nbsp;&nbsp;
                            </div>
                        </form>

                    </div>

                </div>
            </div>
        </div>
        <div class="modal fade" id="alterModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="alterProductInfo">产品配置</h4>
                    </div>
                    <div class="modal-body" style="font-family:微软雅黑;">
                        <form action="alterProductBonus" method="post">
                            <div class="form-group">
                                <label for="alterproductType">产品类型</label>
                                <select class="form-control" id="alterproductType" name="alterproductType">
                                    <option value="流量">流量</option>
                                    <option value="语音">语音</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="alterproductName">产品名称</label>
                                <input class="form-control" id="alterproductName" name="alterproductName">
                            </div>


                            <div class="form-group">
                                <label for="bonusNumber">激励金额</label>
                                <input class="form-control" id="alterBonusNumber" name="alterBonusNumber">
                            </div>

                            <div class="form-group" align="right">

                                <button type="submit" id="alterProductBonus" name="alterProductBonus"
                                        class="btn btn-primary">更改
                                </button>
                                <input type="hidden" name="prodId" id="prodId" value="" />
                            </div>
                        </form>

                    </div>

                </div>
            </div>
        </div>
        <!-- Table -->
        <table class="table" id="glyTable" style="font-family:微软雅黑;table-layout:fixed;">
            <thead>
            <tr>
                <th>类别</th>
                <th>产品</th>
                <th>奖励额(元)</th>
                <th>操作</th>

            </tr>
          </thead>
            <tbody>
            <c:forEach items="${productList}" var="list">
                <tr>
                    <td>${list.prod_type}</td>
                    <td>${list.prod_name}</td>
                    <td>${list.prod_reward}</td>
                    <td>
                        <button type="button" class="btn btn-default btn-xs glyphicon glyphicon-pencil"
                                data-toggle="modal" data-target="#alterModal"
                                onClick="alterData('${list.hbbt_product_model_id}')">
                        </button>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>


    <hr>
    <footer>
        <p align="center">&copy; <span style="font-family:微软雅黑; ">copyright &nbsp;中国电信股份有限公司河北分公司企业信息化部 2016</span></p>
    </footer>
</div>
<!-- /container -->


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->

<script src="static/js/jquery.min.js"></script>
<script src="static/css/dist/js/bootstrap.min.js"></script>
<script src="static/css/assets/js/docs.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="static/css/assets/js/ie10-viewport-bug-workaround.js"></script>
<!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
-->

<script type="text/javascript">
    function alterData(productid) {
        var obj = {"id": productid};
        $.ajax({
            url: "<%= basePath %>/lookProdinfo",
            type: "POST",
            contentType: 'application/json;charset=utf-8', //设置请求头信息
            dataType: "json",
            data: JSON.stringify(obj),            //将Json对象序列化成Json字符串，toJSON()需要引用jquery.json.min.js
            success: function (data) {
//                document.getElementById("userLoginName").value = data.info[0]["user_login_name"];
//                document.getElementById("userRealName").value = data.info[0]["user_realname"];
//                document.getElementById("userTelePhone").value = data.info[0]["user_phone"];
//                document.getElementById("userId").value = data.info[0]["user_model_id"];

                document.getElementById("alterproductType").value = data.info[0]["prod_type"];
                $("#alterproductType").attr("readOnly","true");
                document.getElementById("alterproductName").value = data.info[0]["prod_name"];
                $("#alterproductName").attr("readOnly","true");
                document.getElementById("alterBonusNumber").value = data.info[0]["prod_reward"];
                document.getElementById("prodId").value=data.info[0]["hbbt_product_model_id"];

                console.log(data);
            },
            error: function (res) {
                alert(res.responseText);
            }
        });
    }
</script>


<link rel="stylesheet" type="text/css" href="static/css/jquery.dataTables.css"/>

            <script type="text/javascript" language="javascript" src="static/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="static/js/jquery.dataTables.js">
</script>
<script type="text/javascript" language="javascript" class="init">


    $(document).ready(function() {
        $('#glyTable').DataTable({
            language: {
                processing:     "处理中...",
                search:         "搜索&nbsp;:",
                lengthMenu:    "显示 _MENU_ 项结果",
                info:           "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                infoEmpty:      "显示第 0 至 0 项结果，共 0 项",
                infoFiltered:   "(由 _MAX_ 项结果过滤)",
                infoPostFix:    "",
                loadingRecords: "数据加载中...",
                zeroRecords:    "未找到匹配项",
                emptyTable:     "表中数据为空",
                paginate: {
                    first:      "第一页",
                    previous:   "上一页",
                    next:       "下一页",
                    last:       "尾页"
                },
                aria: {
                    sortAscending:  ": 以升序排列此列",
                    sortDescending: ": 以降序排列此列"
                }
            }
        } );
    } )
</script>

</body>
</html>
